package com.zhc.dejingapi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhc.dejingapi.entity.QingPersonEntity;
import com.zhc.dejingapi.entity.vo.SelectBoxVo;
import com.zhc.dejingapi.mapper.QingPersonMapper;
import com.zhc.dejingapi.service.QingPersonService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhc
 * @since 2024-08-10
 */
@Service
public class QingPersonServiceImpl extends ServiceImpl<QingPersonMapper, QingPersonEntity> implements QingPersonService {

    @Resource
    private QingPersonMapper qingPersonMapper;

    private final RedisTemplate<String,Object> redisTemplate;

    public QingPersonServiceImpl(@Qualifier("redisTemplateWin") RedisTemplate<String, Object> redisTemplate) {
        this.redisTemplate = redisTemplate;
    }


    @Override
    public List<SelectBoxVo> getQingPersonList() {
        List<String> depList= Arrays.asList("注塑部","注塑车间1","注塑车间2");
        QueryWrapper<QingPersonEntity> queryWrapper=new QueryWrapper<QingPersonEntity>();
        queryWrapper.in("psnDep",depList);
        List<QingPersonEntity> qingPersonEntities = qingPersonMapper.selectList(queryWrapper);
        List<SelectBoxVo> selectBoxVos = new ArrayList<>();
        for (QingPersonEntity qingPersonEntity : qingPersonEntities) {
            SelectBoxVo selectBoxVo = new SelectBoxVo();
            selectBoxVo.setText(qingPersonEntity.getPsnName());
            selectBoxVo.setValue(qingPersonEntity.getPsnCode());
            selectBoxVos.add(selectBoxVo);
        }

        return selectBoxVos;
    }

    @Override
    public List<SelectBoxVo> selectPerson(QingPersonEntity qingPersonEntity) {
        return null;
    }
}
